﻿using System;
using Missbot.Service;
using MongoDB.Bson.Serialization.Attributes;

namespace Missbot.AIModule.Schedulers.DailyVtuber
{
    /// <summary>
    /// Vtuber图片记录
    /// </summary>
    public class VtuberPicModel : DbBaseEntity
    {
        /// <summary>
        /// Vtuber名字
        /// </summary>
        public string VtuberName { get; init; }

        /// <summary>
        /// 图片ID
        /// </summary>
        public string FileID { get; init; }

        /// <summary>
        /// 图片URL
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime CreateTime { get; set; } = DateTime.Now;
    }

    public static class VtuberPicModelDA
    {
        /// <summary>
        /// 根据序号获取图片记录
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public static VtuberPicModel GetByIndex(int index)
        {
            return MongoService<VtuberPicModel>.GetOnly(p => true, p => p.CreateTime, false, index);
        }

        /// <summary>
        /// 插入记录
        /// </summary>
        public static void Insert(this VtuberPicModel entity)
        {
            MongoService<VtuberPicModel>.Insert(entity);
        }
    }
}